package by.bsu.scs.util.manager;

import java.util.ResourceBundle;

/**
 * @author Alexey Hursevich
 * @version 1.0
 * 
 * Responsible for getting data from property file.
 * Mostly is used to get SQL queries stored in file.
 */
public class PropertyManager {
	
	private static final String BUNDLE_NAME = "ApplicationResource";
	
	private ResourceBundle resBundle;
		
	public static final String STUDENTS_BY_INSTRUCTOR_ID_SQL = "sql.students.instructor_id";
	public static final String STUDENTS_BY_INSTRUCTOR_DISCIPLINE_GROUP_COURSE_SQL = "sql.students.instructor_id.discipline_id.group_number.course";
	public static final String STUDENTS_BY_INSTRUCTOR_GROUP_COURSE_SQL = "sql.students.instructor_id.group_number.course";
	public static final String STUDENTS_BY_INSTRUCTOR_DISCIPLINE_COURSE_SQL = "sql.students.instructor_id.discipline_id.course";
	public static final String STUDENTS_BY_INSTRUCTOR_DISCIPLINE_GROUP_SQL = "sql.students.instructor_id.discipline_id.group_number";
	public static final String STUDENTS_BY_INSTRUCTOR_DISCIPLINE_SQL = "sql.students.instructor_id.discipline_id";
	public static final String TASK_BY_STUDENT_ID_SQL = "sql.task.student_id";
	public static final String TASK_BY_STUDENT_ID_AND_DISCIPLINE_ID = "sql.task.student_id.discipline_id";
	public static final String MARK_BY_STUDENT_ID_SQL = "sql.mark.student_id";
	public static final String DISCIPLINE_INSTRUCTOR_BY_STUDENT_ID = "sql.disciplineInstructor.student_id";
	public static final String MARK_POLICY_BY_INSTRUCTOR_ID_SQL = "sql.mark_policy.instructor_id";
	public static final String MARK_POLICY_BY_ID_CREATOR_SQL = "sql.mark_policy.id_creator";
	
	private static PropertyManager instance;
	
	private PropertyManager(){
		
	}
	
	/**
	 * Returns PropertyManager instance.
	 * Works as singleton.
	 * 
	 * @return instance
	 */
	public static PropertyManager getInstance(){
		if(instance == null){
			instance = new PropertyManager();
			instance.resBundle = ResourceBundle.getBundle(BUNDLE_NAME);
		}
		return instance;
	}
	
	/**
	 * Gets property value by key.
	 * 
	 * @param key
	 * @return value
	 */
	public String getProperty(String key){
		String value = resBundle.getString(key);
		return value;
	}
}
